const express = require('express')
const app = express()
const port = 3000
const bookList= [
        {
            "bookId": 1410481,
            "bookName": "再一次剑来",
            "isSign": 0,
            "chapterId": 90447754,
            "chapterName": "第一章：异变惊世",
            "authorId": 54737288,
            "authorName": "曲安",
            "totalWords": 0,
            "updateTime": "2025-03-26 09:25:08",
            "cateId": 8351,
            "cateName": "",
            "cateShortName": "武侠仙侠",
            "catePid": 8102,
            "cateFineId": 8102,
            "cateFineName": "武侠仙侠",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410478,
            "bookName": "问天录：初",
            "isSign": 0,
            "chapterId": 90447738,
            "chapterName": "天弃",
            "authorId": 85574088,
            "authorName": "林子熙的熙",
            "totalWords": 0,
            "updateTime": "2025-03-26 09:23:44",
            "cateId": 8353,
            "cateName": "",
            "cateShortName": "武侠仙侠",
            "catePid": 8102,
            "cateFineId": 8102,
            "cateFineName": "武侠仙侠",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410477,
            "bookName": "玄幻，受辱三年从退婚开始逆袭！",
            "isSign": 0,
            "chapterId": 90447735,
            "chapterName": "第一章 退婚？",
            "authorId": 83210425,
            "authorName": "苍生渡",
            "totalWords": 0,
            "updateTime": "2025-03-26 09:23:37",
            "cateId": 8415,
            "cateName": "",
            "cateShortName": "玄幻奇幻",
            "catePid": 8101,
            "cateFineId": 8101,
            "cateFineName": "玄幻奇幻",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410474,
            "bookName": "什么城主？狗都不，当，当的就是城主！",
            "isSign": 0,
            "chapterId": 90447729,
            "chapterName": "第1章 意外穿越 成为城主",
            "authorId": 85305341,
            "authorName": "我不知道an",
            "totalWords": 0,
            "updateTime": "2025-03-26 09:23:09",
            "cateId": 8381,
            "cateName": "",
            "cateShortName": "游戏",
            "catePid": 8107,
            "cateFineId": 8107,
            "cateFineName": "游戏",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1340903,
            "bookName": "重生七六年",
            "isSign": 0,
            "chapterId": 90447700,
            "chapterName": "   213章   江永亮受伤",
            "authorId": 53390848,
            "authorName": "罗夫子",
            "totalWords": 474872,
            "updateTime": "2025-03-26 09:18:10",
            "cateId": 8473,
            "cateName": "",
            "cateShortName": "都市",
            "catePid": 8103,
            "cateFineId": 8103,
            "cateFineName": "都市",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410042,
            "bookName": "四合院：我有空间种田虐禽",
            "isSign": 1,
            "chapterId": 90447692,
            "chapterName": "第15章 特殊空间",
            "authorId": 56313747,
            "authorName": "豆腐0",
            "totalWords": 51192,
            "updateTime": "2025-03-26 09:16:00",
            "cateId": 8476,
            "cateName": "",
            "cateShortName": "都市",
            "catePid": 8103,
            "cateFineId": 8103,
            "cateFineName": "都市",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1409637,
            "bookName": "我以煞气诛妖魔",
            "isSign": 0,
            "chapterId": 90443919,
            "chapterName": "第5章磨炼",
            "authorId": 85681334,
            "authorName": "金喻",
            "totalWords": 16369,
            "updateTime": "2025-03-26 09:15:29",
            "cateId": 8414,
            "cateName": "",
            "cateShortName": "玄幻奇幻",
            "catePid": 8101,
            "cateFineId": 8101,
            "cateFineName": "玄幻奇幻",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410278,
            "bookName": "剑修无敌",
            "isSign": 0,
            "chapterId": 90447702,
            "chapterName": "20章  天变",
            "authorId": 54397972,
            "authorName": "胜仔哥",
            "totalWords": 50661,
            "updateTime": "2025-03-26 09:13:50",
            "cateId": 8351,
            "cateName": "",
            "cateShortName": "武侠仙侠",
            "catePid": 8102,
            "cateFineId": 8102,
            "cateFineName": "武侠仙侠",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410415,
            "bookName": "鬼门十三针：我以阎王叩天门",
            "isSign": 0,
            "chapterId": 90447666,
            "chapterName": "第四章 丧尸传闻",
            "authorId": 85576116,
            "authorName": "蓝色多瑙河的柳絮",
            "totalWords": 10482,
            "updateTime": "2025-03-26 09:07:32",
            "cateId": 8473,
            "cateName": "",
            "cateShortName": "都市",
            "catePid": 8103,
            "cateFineId": 8103,
            "cateFineName": "都市",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410039,
            "bookName": "三国：我成了曹操的致命毒药",
            "isSign": 1,
            "chapterId": 90447660,
            "chapterName": "第13章 嫡母威严",
            "authorId": 85681128,
            "authorName": "林金鸿",
            "totalWords": 46029,
            "updateTime": "2025-03-26 09:05:00",
            "cateId": 8291,
            "cateName": "",
            "cateShortName": "历史",
            "catePid": 8104,
            "cateFineId": 8104,
            "cateFineName": "历史",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410181,
            "bookName": "重生70：从拒绝渣女开始致富",
            "isSign": 1,
            "chapterId": 90447635,
            "chapterName": "第13章 乡愁",
            "authorId": 82941809,
            "authorName": "豆腐",
            "totalWords": 30415,
            "updateTime": "2025-03-26 09:01:00",
            "cateId": 8472,
            "cateName": "",
            "cateShortName": "都市",
            "catePid": 8103,
            "cateFineId": 8103,
            "cateFineName": "都市",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1410179,
            "bookName": "无上仙秦：从绑定大秦国运开始成至高",
            "isSign": 1,
            "chapterId": 90447639,
            "chapterName": "第15章 雷火炼真形，剑侍鼎炉",
            "authorId": 85680114,
            "authorName": "又闲又多余",
            "totalWords": 32047,
            "updateTime": "2025-03-26 09:01:00",
            "cateId": 8291,
            "cateName": "",
            "cateShortName": "历史",
            "catePid": 8104,
            "cateFineId": 8104,
            "cateFineName": "历史",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1409588,
            "bookName": "末世危机：混合生命禁区",
            "isSign": 0,
            "chapterId": 90447619,
            "chapterName": "第五章 危机",
            "authorId": 85697551,
            "authorName": "奕无双",
            "totalWords": 17978,
            "updateTime": "2025-03-26 09:00:00",
            "cateId": 8442,
            "cateName": "",
            "cateShortName": "科幻",
            "catePid": 8105,
            "cateFineId": 8105,
            "cateFineName": "科幻",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1409502,
            "bookName": "万劫道主",
            "isSign": 0,
            "chapterId": 90447610,
            "chapterName": "第三十六章：险象环生觅钥匙，神秘力量初现",
            "authorId": 85678134,
            "authorName": "大叔墨染",
            "totalWords": 88144,
            "updateTime": "2025-03-26 09:00:00",
            "cateId": 8412,
            "cateName": "",
            "cateShortName": "玄幻奇幻",
            "catePid": 8101,
            "cateFineId": 8101,
            "cateFineName": "玄幻奇幻",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        },
        {
            "bookId": 1409384,
            "bookName": "九天一帝",
            "isSign": 0,
            "chapterId": 90447601,
            "chapterName": "第十一章 天玄初遇",
            "authorId": 85684437,
            "authorName": "不喝酒",
            "totalWords": 17330,
            "updateTime": "2025-03-26 09:00:00",
            "cateId": 8353,
            "cateName": "",
            "cateShortName": "武侠仙侠",
            "catePid": 8102,
            "cateFineId": 8102,
            "cateFineName": "武侠仙侠",
            "coverUrl": "",
            "level": 0,
            "serialStatus": 0,
            "chapterLevel": 0
        }
    ]

app.get('/book/author/:bookName', (req, res) => {
    bookName = req.params.bookName;
    for (let index = 0; index < bookList.length; index++) {
        const element = bookList[index];
        if (element.bookName === bookName) {
            res.send(`《${bookName}》的作者是${element.authorName}`);
        }
    }
});

app.get('/book/updateTime/:bookName', (req, res) => {
    bookName = req.params.bookName;
    for (let index = 0; index < bookList.length; index++) {
        const element = bookList[index];
        if (element.bookName === bookName) {
            res.send(`《${bookName}》的更新时间是${element.updateTime}`);
        }
    }
});

app.get('/book/category/:bookName', (req, res) => {
    bookName = req.params.bookName;
    for (let index = 0; index < bookList.length; index++) {
        const element = bookList[index];
        if (element.bookName === bookName) {
            res.send(`《${bookName}》的类型是${element.cateShortName}`);
        }
    }
});

app.listen(port, () => {
    console.log(`Server is running on port ${port}`);
});